<?php
namespace app\service\validate;
use think\Validate;
class ServiceProduct extends Validate {
    //验证字段
    protected $rule = [
        'chat_id' => ['require','number'],
        'service_chat_id' => ['require'],
        'status' => ['require','number'],
        'is_delete' => ['require','number'],
        'create_time' => ['require','number'],
        'last_service_account_id' => ['require','number'],
        'merchant_id' => ['require','number'],
        'is_close' => ['require','number'],
        'close_time' => ['require','number'],
        'product_id' => ['require','number'],
        'product_info' => ['require'],
        'img_url' => ['require'],
        'id' => ['require','number'],
    ];
    //返回消息
    protected $message = [
        'chat_id.require' => '窗口id必须',
        'chat_id.number' => '窗口id不是数字',
        'service_chat_id.require' => '服务id必须',
        'status.require' => '状态必须',
        'status.number' => '状态不是数字',
        'is_delete.require' => '已删除必须',
        'is_delete.number' => '已删除不是数字',
        'create_time.require' => '创建时间必须',
        'create_time.number' => '创建时间不是数字',
        'last_service_account_id.require' => '最后的客服账号id必须',
        'last_service_account_id.number' => '最后的客服账号id不是数字',
        'merchant_id.require' => '商城id必须',
        'merchant_id.number' => '商城id不是数字',
        'is_close.require' => '已关闭必须',
        'is_close.number' => '已关闭不是数字',
        'close_time.require' => '关闭时间必须',
        'close_time.number' => '关闭时间不是数字',
        'product_id.require' => '产品id必须',
        'product_id.number' => '产品id不是数字',
        'product_info.require' => '产品信息必须',
        'img_url.require' => '图片链接必须',
        'id.require' => 'id必须',
        'id.number' => 'id不是数字',
    ];

    // except_id 场景
    public function sceneExcept_id(){
        return $this->only(['chat_id','service_chat_id','status','is_delete','create_time','last_service_account_id','merchant_id','is_close','close_time','product_id','product_info','img_url']);
    }

    // only_id 场景
    public function sceneOnly_id(){
        return $this->only(['id']);
    }

    // all_field 场景
    public function sceneAll_field(){
        return $this->only(['id','chat_id','service_chat_id','status','is_delete','create_time','last_service_account_id','merchant_id','is_close','close_time','product_id','product_info','img_url']);
    }
}
